(function(win, doc){

    function Toast(msg) {
        var _this = this;
        _this.message = msg;
        _this._create();
    }
    Toast.prototype._create = function() {
        var _this = this;
        var $el = doc.createElement('div');
        $el.className = 'ui-toast';

        var $content = doc.createElement('span')
        $content.className = 'ui-toast-content';
        $content.innerHTML = _this.message;
        $el.appendChild($content);


        doc.body.appendChild($el);
        _this.$el = $el;
    }

    Toast.prototype.open = function() {
        var _this = this;
        _this.$el.style.display = 'block';
        _this.$el.style.top = (win.innerHeight * 0.5) + 'px';

        setTimeout(function (){
            _this.close();
        }, 2000);
    }

    Toast.prototype.close = function() {
        var _this = this;
        _this.$el.style.display = 'none';
        setTimeout(function (){
            doc.body.removeChild(_this.$el);
        }, 3000)        
     }

    win.toast = function(message) {
        new Toast(message).open();
    }

     // export const toast =  win.toast;

})(window, document);